package com.xjoyt.pay.master.po;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 提现明细O
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_cash_detail")
public class CashDetail {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "cash_detail_id", length = 36)
	public String id;

	/**
	 * 提现
	 */
	@ManyToOne(targetEntity = Cash.class, cascade = {})
	@JoinColumn(name = "cash_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public Cash cash;

	/**
	 * 流水号
	 */
	@Column(name = "`no`", length = 50)
	public String no;

	/**
	 * 上游流水号
	 */
	@Column(name = "trade_no", length = 255)
	public String tradeNo;

	/**
	 * 提现状态(null:提现中，true：提现成功，false：提现失败)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_success")
	public Boolean success;

	/**
	 * 到账状态(true：到账成功，false：到账失败)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_pay")
	public Boolean pay;

	/**
	 * 提现金额(分)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 到账金额(分)
	 */
	@Column(name = "cash_money")
	public Long cashMoney;

	/**
	 * 提现费率(‰)
	 */
	@Column(name = "rate")
	public Double rate;

	/**
	 * 提现成本费率(‰)
	 */
	@Column(name = "cost_rate")
	public Double costRate;

	/**
	 * 支付通道费率(%)
	 */
	@Column(name = "channel_rate")
	public Double channelRate;

	/**
	 * 提现固定手续费(分)
	 */
	@Column(name = "poundage")
	public Long poundage;

	/**
	 * 提现成本手续费(分)
	 */
	@Column(name = "cost_poundage")
	public Long costPoundage;

	/**
	 * 支付通道提现手续费(分)
	 */
	@Column(name = "channel_poundage")
	public Long channelPoundage;

	/**
	 * 上限手续费(分)
	 */
	@Column(name = "`limit`")
	public Long limit;

	/**
	 * 上限成本手续费(分)
	 */
	@Column(name = "cost_limit")
	public Long costLimit;

	/**
	 * 支付通道上限手续费(分)
	 */
	@Column(name = "channel_limit")
	public Long channelLimit;

	/**
	 * 下限手续费(分)
	 */
	@Column(name = "`minimum`")
	public Long minimum;

	/**
	 * 下限成本手续费(分)
	 */
	@Column(name = "`cost_minimum`")
	public Long costMinimum;

	/**
	 * 支付通道下限手续费(分)
	 */
	@Column(name = "channel_minimum")
	public Long channelMinimum;

	/**
	 * 通道
	 */
	@ManyToOne(targetEntity = Channel.class, cascade = {})
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public Channel channel;

	/**
	 * 通道名称
	 */
	@Column(name = "channel_name", length = 50)
	public String channelName;

	/**
	 * 通道编号
	 */
	@Column(name = "channel_no", length = 50)
	public String channelNo;

	/**
	 * 订单
	 */
	@ManyToOne(targetEntity = Order.class, cascade = {})
	@JoinColumn(name = "order_id", foreignKey = @ForeignKey(name = "none"))
	// @JsonIgnore
	public Order order;

	/**
	 * 订单号
	 */
	@Column(name = "order_no", length = 50)
	public String orderNo;

	/**
	 * 提现类型(false：自动，true：手动)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "cash_type")
	public Boolean cashType;

	/**
	 * 适配器地址
	 */
	@Column(name = "`url`", length = 255)
	public String url;
	
	/**
	 * 提现成功日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;

}
